function [IA_Relation] = IA_Relation_Constraints_Hogge(IA_Relation1, IA_Relation2, IA_Relation3)
%IA_Relation_Constraints Constraints(R1, R2)
%   Constraints function as per James F. Allen's Interval Algebra (1983)

persistent M1;
persistent M2;
persistent M3;
persistent M4;

if isempty(M1)
  M1 = IA_Hogge_Matrix1();
end
if isempty(M2)
  M2 = IA_Hogge_Matrix2();
end
if isempty(M3)
  M3 = IA_Hogge_Matrix3();
end
if isempty(M4)
  M4 = IA_Hogge_Matrix4();
end

num1 = IA_Relation_To_Number(IA_Relation1);
num2 = IA_Relation_To_Number(IA_Relation2);

num1a = mod(num1, 2^7);
num2a = mod(num2, 2^7);

num1b = floor(num1 / 2^7);
num2b = floor(num2 / 2^7);

IA_Relation = IA_Relation_Null();

if num1a ~= 0 && num2a ~= 0
  IA_Relation = M1(num1a, num2a);
end

if num1a ~= 0 && num2b ~= 0
  IA_Relation = IA_Relation_Union(IA_Relation, M2(num1a, num2b));
end

if num1b ~= 0 && num2a ~= 0
  IA_Relation = IA_Relation_Union(IA_Relation, M3(num1b, num2a));
end

if num1b ~= 0 && num2b ~=0
  IA_Relation = IA_Relation_Union(IA_Relation, M4(num1b, num2b));
end

end